﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sispe.Entities;

namespace Sispe.Repository.Mapping
{
    public class FOTOCHECKMap: EntityTypeConfiguration<FOTOCHECK>
    {
        public FOTOCHECKMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            this.Property(t => t.Número)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.Descripcion)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("FOTOCHECK");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Dni).HasColumnName("Dni");
            this.Property(t => t.Número).HasColumnName("Número");
            this.Property(t => t.Descripcion).HasColumnName("Descripcion");


            this.HasRequired(t => t.TRABAJADOR)
                .WithMany(t => t.FOTOCHECKS)
                .HasForeignKey(d => d.Dni);
        }
    }
}
